package pl.grabar.clinic.client.web.actions.reception.patient;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;

import pl.grabar.clinic.core.dao.Dao;
import pl.grabar.clinic.core.domain.person.Patient;
import pl.grabar.clinic.core.domain.person.data.Address;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.Preparable;

@Action("new")
@InterceptorRef("grabarStack")
@Results({ @Result(name = "success", location = "edit.jsp"), @Result(name = "input",  type = "redirectAction", location = "list") })
public class NewPatientAction extends ActionSupport implements Preparable {

	private static final long serialVersionUID = -4343000529096508886L;

//	private static final Log LOG = LogFactory.getLog(SavePatientAction.class);

	@Autowired
	private Dao<Patient> patientDao;

	private Patient patient;

	@Override
	public void prepare() throws Exception {
		patient = new Patient();
		patient.setAddress(new Address());
	}

	@Override
	public void validate() {
	}

	@Override
	public String execute() throws Exception {
		return SUCCESS;
	}

	/* AKCESORY */

	public Patient getPatient() {
		return patient;
	}

	public void setPatient(Patient patient) {
		this.patient = patient;
	}

	public void setPatientDao(Dao<Patient> patientDao) {
		this.patientDao = patientDao;
	}

}
